<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->

<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>供货单管理</title>
<link href="${request.getContextPath()}/Public/assets/admin/css/css.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/global/plugins/font-awesome/css/font-awesome.min.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/global/plugins/simple-line-icons/simple-line-icons.min.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/global/plugins/bootstrap/css/bootstrap.min.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/global/plugins/uniform/css/uniform.default.css"
	rel="stylesheet" type="text/css">
<link rel="${request.getContextPath()}/Public/stylesheet"
	type="text/css"
	href="assets/global/plugins/jquery-notific8/jquery.notific8.min.css" />
<link
	href="${request.getContextPath()}/Public/assets/global/css/components-rounded.css"
	id="style_components" rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/global/css/plugins.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/admin/css/layout.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/admin/css/themes/default.css"
	rel="stylesheet" type="text/css" id="style_color">
<link
	href="${request.getContextPath()}/Public/assets/admin/css/custom.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/global/plugins/bootstrap-datepicker/css/bootstrap-datepicker.min.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/global/css/kkpager.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/admin/css/common.css"
	rel="stylesheet" type="text/css">
<link rel="shortcut icon"
	href="${request.getContextPath()}/Public/assets/global/plugins/datatables/media/images/favicon.ico">
<link href="${request.getContextPath()}/Public/css/customerDetail.css"
	rel="stylesheet" type="text/css">
<script type="text/javascript" src="${request.getContextPath()}/Public/My97DatePicker/WdatePicker.js"></script>
<script>
	BASE_URL = '${request.getContextPath()}'
</script>
<body class="page-header-top-fixed">
	<div class="page-header">
		<!--头部开始-->
		<#include "/include/top.html" />
		<!-- 头部信息结束 -->
		<!-- 头部菜单开始 -->
		<#include "/include/top_menu.html" />
		<!-- 头部菜单结束 -->
	</div>

	<!-- BEGIN PAGE CONTAINER -->
	<div class="page-container">
		<div class="page-content">
			<div class="container-fluid">
				<!-- 当前位置提示开始 -->
				<ul class="page-breadcrumb breadcrumb">
					<li><a href="#">首页</a><i class="fa fa-circle"></i></li>
					<li class="active">废金属管理<i class="fa fa-circle"></i>
					</li>
					<li class="active">供货单管理</li>
				</ul>
				<div class="row margin-top-10">
					<div class="col-md-12">
						<div class="col-md-12">
						<div class="portlet light bordered">
							<div class="portlet-body" style="height: 13px;padding-top: 0px">
								<div style="float: left;">
									视图： 
									<a status="1" href="#" onclick="changeTab(this)" <#if status ?? && status == 1>class="btn green"<#else>class="btn btn-default"</#if> >已通过</a>
									<a status="0" href="#" onclick="changeTab(this)" <#if status ?? && status == 0>class="btn green"<#else>class="btn btn-default"</#if> >待审核</a>
									<a status="3" href="#" onclick="changeTab(this)" <#if status ?? && status == 3>class="btn green"<#else>class="btn btn-default"</#if> >已过期</a>
									<a status="2" href="#" onclick="changeTab(this)" <#if status ?? && status == 2>class="btn green"<#else>class="btn btn-default"</#if> >未通过</a>
								</div>
								<div style="float: right;">
									<img id="imgs" name="imgs" style="width: 25px;height:25px" src="${request.getContextPath()}/Public/images/huishouzhan.png"><a href="${request.getContextPath()}/supply/orderListWeb.do?status=4&saleType=${saleType!''}">回收站</a>
								</div>
								<input type="hidden" id="status" name="status" value="${status}">
							</div>
						</div>
					</div>
						<div class="portlet light bordered">
						<form action="${request.getContextPath()}/supply/orderListWeb.do" method="post">
							<table>
								<tr>
									<td>
										<div style="width:110px; float:left;">
											<select class="form-control" name="type" id="type">
												<option value="1" <#if type?? &&type="1">selected</#if>>信息标题</option>
												<option value="2" <#if type?? &&type="2">selected</#if>>手机</option>
												<option value="3" <#if type?? &&type="3">selected</#if>>姓名</option>
												<option value="4" <#if type?? &&type="4">selected</#if>>公司名</option>
												<option value="5" <#if type?? &&type="5">selected</#if>>创建人</option>
											</select>
										</div>
										<div style="width:390px; float:left; margin-left:15px;">
											<input type="text" name="recommend" id="recommend" value="${recommend!''}" class="form-control" />
										</div>
									</td>
									<td>
										<div style="float:right; margin-left:15px; padding-top: 7px;">
											<label for="high">货物所在地 ： </label>
										</div>
									</td>
									<td>
										<div style="width:110px; float:left;">
											<select class="form-control" name="prov" id="prov" onchange="getCity()">
												<option value="" selected>--请选择--</option>
												<#list areas as area>
													<option value="${(area.id)!''}" <#if prov?? &&prov=area.id	>selected</#if>>${(area.name)!''}</option> 
												</#list>
											</select>
										</div>
										<div class="col-sm-2" style="display: none;width: 150px;" id="gcity">
											<select class="form-control" name="city" id="city"></select>
										</div>
									</td>
									<td><input type="checkbox" id="isPriced" name="isPriced" <#if isPriced?? >checked</#if>/>有价格</td>
								</tr>
								<tr>
									<td height="20px;"></td>
									<td height="20px;"></td>
									<td height="20px;"></td>
									<td height="20px;"></td>
								</tr>
								<tr>
									<td>
										<div style="width:110px; float:left;">
											<select class="form-control" name="attribute" id="attribute">
												<option value="1" <#if attribute?? &&attribute="1">selected</#if>>发布时间</option>
												<option value="2" <#if attribute?? &&attribute="2">selected</#if>>更新时间</option>
											</select>
										</div>
										<div style="width:200px; float:left; margin-left:15px;">
											<input class="form-control input-small2  input-inline" type="search" placeholder="成交时间" name="startTime" id="startTime" value="${startTime!''}" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})">&nbsp;至
										</div>
										<div style="width:200px; float:left; margin-left:15px;">
											<input class="form-control input-small2  input-inline" type="search" placeholder="结束时间" name="endTime" id="endTime"  value="${endTime!''}"  onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})">
										</div>
									</td>
									<td>
										<div style="float:right; margin-left:15px; padding-top: 7px;">
											<label for="high">分&nbsp;&nbsp;类： </label>
										</div>
										
									</td>
									<td>
										<div style="width:110px; float:left;">
											<select class="form-control" name="itemid" id="itemid">
												<option value="" selected>--请选择--</option>
												<#list item as it>
													<option value="${(it.id)!}" <#if itemid?? &&itemid=it.id>selected</#if>>${(it.name)!}</option> 
												</#list>
											</select>
										</div>
										&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
										<button class="btn green" onclick="refet()" >重置</button>
										<button class="btn green" style="margin-left:15px;">
											<i class="fa fa-search"></i> 搜索 
										</button>
									</td>
									<td>&nbsp;</td>
								</tr>
							</table>
							<input type="hidden" id="isGet" name="isGet" value="false">
							<input type="hidden" id="status" name="status" value="${status}">
							</form>
						</div>
						<input type="hidden" id="xuanzhong" name="xuanzhong">
						
						<div class="portlet light bordered">
							<div class="portlet-body">
								
								<div class="clearfix">
									<div style="width:100px; float:left;">
										<button class="btn green" id="del" onclick="updateById('1')">批量更新</button>
									</div>
									<div style="width:100px; float:left;">
										<button class="btn green" id="del" onclick="updateById('2')">批量删除</button>
									</div>
									
									<input type="hidden" id="attributeHidden"/>
									<input type="hidden" id="operatorHidden"/>
									<input type="hidden" id="contentHidden"/>
									<div style="width:100px; float:right;">
										<button id="export" class="btn green" onclick="supplyExport();" style="float: right">导出</button>
									</div>
									<div style="width:100px; float:right;">
										<button id="addOffer" class="btn green" style="float: right" onclick="insertSupply()">新建供货单</button>
									</div>
								</div>
								<br />
								<!-- <h3>最新报盘</h3> 
								<div class="dataDiv">
									<table id="grid" class="table table-striped table-bordered table-advance table-hover ttTbl">
										<tr>
											<td>
												<div class="loadingAjax">
												</div>
											</td>
										</tr>
									</table>
									<br />
								</div>
								-->
								<div class="dataDiv">
									<table class="table table-striped table-bordered table-hover ttTbl" id="myTable">
										<thead>
										<tr align="center" >
											<th class="table-checkbox">
												<input type="checkbox" class="group-checkable" data-set="#myTable .checkboxes"/>
											</th>
											<th>手机</th>
											<th>分类</th>
											<th>信息标题</th>
											<th>货物所在地</th>
											<th>数量</th>
											<th>价格</th>
											<th>信息有效期</th>
											<th>创建人</th>
											<th>更新时间</th>
											<th>操作</th>
										</tr>
										</thead>
										<#list supplyList as supply>
											<tr>
												<td><input name="checkboxes" class="checkboxes" type="checkbox" value="${supply.id?if_exists}"></td>
												<td>${supply.phone}</td>
												<td>${supply.name}</td>
												<td><a href="${request.getContextPath()}/supply/supplyDetail.do?id=${supply.id}">${supply.infoTitle}</a></td>
												<td>
													<#if supply.proyName?? && supply.cityName?? && supply.proyName != supply.cityName>
														${supply.proyName}
													</#if>
													${supply.cityName}
												</td>
												<td>${(supply.usableQuantity?string("#.#####"))!}</td>
												<td>
													<#if supply.priceNegotiable ?? && supply.priceNegotiable == 1>
														面议
													<#elseif supply.price??>
														${supply.price}
													</#if>
												</td>
												<td>
													<#if supply.expiryType ?? && supply.expiryType == 0>
														一周
													<#elseif supply.expiryType?? && supply.expiryType == 1>
														一个月
													</#if>
												</td>
												<td>
													<#if supply.isCreatedByCustomer ?? && supply.isCreatedByCustomer == 0>
														${supply.uname}
													<#elseif supply.isCreatedByCustomer?? && supply.isCreatedByCustomer == 1>
														<#if supply.customerName ?? && supply.customerName != ''>
															${supply.customerName}
														<#elseif supply.nickName ??>
															${supply.nickName}
														</#if>
													</#if>
												</td>
												<td>
													<#if supply.updatedAt ??>
														${supply.updatedAt}
													<#else>
														--
													</#if>
												</td>
												<td>
													<#if supply.infoStatus ?? && supply.infoStatus == 1>
														<a href="${request.getContextPath()}/supply/supplyDetailById.do?suppid=${supply.id}&status=1" class="btn btn-xs green">修改</a>
														<#if supply.usableQuantity ?? && (supply.usableQuantity > 0)>
															<a href="${request.getContextPath()}/order/toAddOrderBySupply.do?id=${supply.id}" class="btn btn-xs green">生成订单</a>
														</#if>
													<#else>
														<a href="${request.getContextPath()}/supply/supplyDetailById.do?suppid=${supply.id}&status=1" class="btn btn-xs green">修改</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
													</#if>
												</td>
											</tr>
										</#list>
									</table>
								</div>
								<div style="width:80%;margin:0 auto;">
									<div id="kkpager"></div>
									<input type="hidden" value="${totalPage}" id="totalPage">
									<input type="hidden" value="${totalRecords}" id="totalRecords">
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>

	<!-- 内容结束 -->
	<!-- 底部开始 -->
	<#include "/include/foot.html" />
	<!-- 底部结束 -->

<script
	src="${request.getContextPath()}/Public/assets/global/plugins/jquery.min.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/global/plugins/jquery-migrate.min.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/global/plugins/jquery-ui/jquery-ui.min.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/global/plugins/bootstrap/js/bootstrap.min.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/global/plugins/bootstrap-hover-dropdown/bootstrap-hover-dropdown.min.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/global/plugins/jquery-slimscroll/jquery.slimscroll.min.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/global/plugins/jquery.blockui.min.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/global/plugins/jquery.cokie.min.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/global/plugins/uniform/jquery.uniform.min.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/global/plugins/jquery-notific8/jquery.notific8.min.js"></script>

<script
	src="${request.getContextPath()}/Public/assets/global/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"
	type="text/javascript"></script>

<script
	src="${request.getContextPath()}/Public/assets/global/scripts/metronic.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/admin/scripts/layout.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/global/plugins/kkpager.min.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/admin/scripts/commonUtils.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/admin/scripts/priceFloat.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/admin/scripts/tc.min.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/admin/scripts/ajaxfileupload.js"
	type="text/javascript"></script>
<!-- select2控件 -->
<script type="text/javascript" src="${request.getContextPath()}/Public/assets/global/plugins/select2/select2.js"></script>
<script type="text/javascript" src="${request.getContextPath()}/Public/assets/global/plugins/select2/select2_locale_zh-CN.js"></script>

<script>

$(function() {
	Metronic.init(); // init metronic core componets
	Layout.init(); // init layout
	//搜索下拉框
	//toSelect2();
	//初始化分页插件	
	toPage();
	CommonUtils.checkInit();
});

	function exportOffer(){
		var attribute=$("#attribute").val();
		var operator=$("#operator").val();
		var content=$("#content").val();
		var urlParam="?attribute="+attribute+"&operator="+operator+"&content="+content;
		window.location = "${request.getContextPath()}/business/exportOffer.do"+ urlParam;
	}

	//新建供货单
	function insertSupply(){
		window.location.href="${request.getContextPath()}/supply/insert.do?";
	}
	
	//页签切换 tab
	function changeTab(Object){
		var auditStatus = $(Object).attr("status");
		window.location.href="${request.getContextPath()}/supply/orderListWeb.do?status="+auditStatus;
	}
	//重置
	function refet(){
		$("#type").val("");
		$("#recommend").val("");
		$("#prov").val("");
		$("#city").val("");
		$("#attribute").val("");
		$("#startTime").val("");
		$("#endTime").val("");
		$("#itemid").val("");
	}
	
	//选择省级地区
	function getCity(){
		var parentId = $("#prov").val();
		if(parentId){
			$("#city").find('option').remove();
			$.ajax({
				type : "POST",
				url : "${request.getContextPath()}/Purchase/getChildAreas.do?parentId="+parentId,
				dataType : "json",
				success : function(areas) {
					if(areas && areas instanceof Array && areas.length>0){
						$("#gcity").show();
						var area;
						$("#city").append("<option value=''>请选择</option>");
						for(var i=0;i<areas.length;i++){
							area = areas[i];							
							if(area && typeof area=='object'){
								$("#city").append('<option  value="'+ area.id +'">'+ area.name +'</option>');
							}
						}
					}else{
						if(areas==null){
							$("#gcity").hide();
						}
					}
				}
			});
		}
	}
	//批量删除
	function updateById(type){
		var str=document.getElementsByName("checkboxes");
		var objarray=str.length;
		var chestr="";
		for (i=0;i<objarray;i++)
		{
		  if(str[i].checked == true)
		  {
		   chestr+=str[i].value+",";
		  }
		}
		if(chestr == "")
		{
			CommonUtils.succModal("系统提示", "请选择一条记录！");
		}else{
		  $.ajax({  
		        url : "${request.getContextPath()}/supply/updateById.do?id="+chestr+"&type="+type,   
		        dataType : 'json', 
				success : function(data) {
					 if(data.result=="success"){
						 alert("操作成功!");
						 CommonUtils.succModal("系统提示", "操作成功!");
					 }else{
						 alert("操作失败!");
						 CommonUtils.succModal("系统提示", "操作失败!");
					 }
					 window.location.href="${request.getContextPath()}/supply/orderListWeb.do?status=1";
		        },  
		        error : function(data)//服务器响应失败处理函数  
		        {  
		         alert("请求失败");
		        }  
		    }); 
		}
	}
	
	function supplyExport() {
		var checks = CommonUtils.getCheckedBoxs().join(",");
		var type = $("#type").val();
		var recommend = $("#recommend").val();
		var prov = $("#prov").val();
		var city = $("#city").val();
		var attribute = $("#attribute").val();
		var startTime = $("#startTime").val();
		var endTime = $("#endTime").val();
		var itemid = $("#itemid").val();
		var status = $("#status").val();
		//var name = encodeURIComponent(encodeURIComponent($("#name").val()));

		var urlParam = "?type=" + type + "&recommend=" + recommend
				+ "&prov=" + prov + "&city=" + city
				+ "&attribute=" + attribute+ "&startTime=" + startTime+ "&endTime=" + endTime+"&itemid="+itemid+"&checks="+checks+"&status="+status;
		
		window.location = "${request.getContextPath()}/supply/poolExportDel.do"
				+ urlParam;
	}
	
	

	//分页
	function toPage(){
		//alert($("#status").val());
		function getParameter(name) {
			var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
			var r = window.location.search.substr(1).match(reg);
			if (r != null)
				return unescape(r[2]);
			return null;
		}
		
		var totalPage = $('#totalPage').val();
		var totalRecords = $('#totalRecords').val();
		var pageNo = getParameter('pno');
		if (!pageNo) {
			pageNo = 1;
		}
		
		//生成分页
		//有些参数是可选的，比如lang，若不传有默认值
		kkpager.generPageHtml({
			pno : pageNo,
			//总页码
			total : totalPage,
			//总数据条数
			totalRecords : totalRecords,
	
			getLink : function(n) {
				return this.hrefFormer + this.hrefLatter + "?isGet=true&pno=" + n+"&depotno="+$("#depotno").val()+"&ownerName="+$("#ownerName").val()+
						"&satstatus="+$("#satstatus").val()+"&startTime="+$("#startTime").val()+"&endTime="+$("#endTime").val()+
						"&warehouse="+$("#warehouse").val()+"&watstatus="+$("#watstatus").val()+"&status="+$("#status").val()+
						"&prov="+$("#prov").val()+"&city="+$("#city").val()+"&type="+$("#type").val()+"&recommend="+ encodeURI(encodeURI($("#recommend").val())) +
						"&itemid="+$("#itemid").val()+"&attribute="+$("#attribute").val();
			}
		});
	}
</script>

</body>
</html>